# include<ros/ros.h>
#include<std_msgs/String.h>

void sub_msg(const std_msgs::String::ConstPtr &msg)
{

    ROS_INFO("订阅到的消息:%s",msg->data.c_str());
}

int main(int argc, char *argv[])
{
    setlocale(LC_ALL,"");
    ros::init(argc,argv,"cpp_sub_node");
    ros::NodeHandle nd;
    ros::Subscriber sub = nd.subscribe("home",10,sub_msg);
    ros::spin();    // 回头
    return 0;
}
